﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using OgilvyOne.BLL;
using OgilvyOne.Model;
using OgilvyOne.SqlServerDAL;
using ret.BLL;

public partial class admin_vico_edmreg_detail : AdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            regModel rm = GetRegModel(int.Parse(Request.Params["id"].ToString()));
            this.luname.Text = rm.Regname;
            this.lsex.Text = rm.Sex;
            this.lemail.Text = rm.Email;
            this.lmobile.Text = rm.Regmobile;
            this.laddress.Text = rm.Regaddress;
            this.lpostalcode.Text = rm.Postalcode;
            this.lperiod.Text = rm.Period;
            this.lanswer.Text = rm.Answer;
            this.laddtime.Text = rm.AddTime.ToString("yyyy/MM/dd");
        }
    }
    public regModel GetRegModel(int id)
    {
        string COLUMN_SQL = "select id,uname,email,mobile,address,postalcode,period,answer,sex,addtime from VICO_register where id=@id";
        regModel cum = new regModel();
        SqlParameter[] parms = new SqlParameter[] { 
                new SqlParameter("@id", SqlDbType.Int)};
        parms[0].Value = id;


        using (SqlDataReader rdr = SQLHelper.ExecuteReader(SQLHelper.CONN_STRING_NON_DTC, CommandType.Text, COLUMN_SQL, parms))
        {
            if (rdr.Read())
            {
                if (!rdr.IsDBNull(0)) cum.ID = rdr.GetInt32(0);
                if (!rdr.IsDBNull(1)) cum.Regname = rdr.GetString(1);
                if (!rdr.IsDBNull(2)) cum.Email = rdr.GetString(2);
                if (!rdr.IsDBNull(3)) cum.Regmobile = rdr.GetString(3);
                if (!rdr.IsDBNull(4)) cum.Regaddress = rdr.GetString(4);
                if (!rdr.IsDBNull(5)) cum.Postalcode = rdr.GetString(5);
                if (!rdr.IsDBNull(6)) cum.Period = rdr.GetString(6);
                if (!rdr.IsDBNull(7)) cum.Answer = rdr.GetString(7);
                if (!rdr.IsDBNull(8)) cum.Sex = rdr.GetString(8);
                if (!rdr.IsDBNull(9)) cum.AddTime = rdr.GetDateTime(9);
            }
        }
        return cum;
    }
}
